wayland: Add support for gtk_window_set_modal
authorJonas Ådahl <jadahl@gmail.com>
Fri, 6 Mar 2015 03:40:12 +0000 (11:40 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 23 Apr 2015 08:09:15 +0000 (16:09 +0800)
Add two new requests to the gtk_surface interface: set_modal and
unset_modal. The server will currently not do anything special with
input focus, and its up to the client to ignore events on the parent
surface.

This commit bumps the gtk_shell interface version to 2. By connecting to
a Wayland server with another gtk_shell interface version any features
depending on the gtk_shell protocol will not be available.

https://bugzilla.gnome.org/show_bug.cgi?id=745721

gdk/wayland/gdkprivate-wayland.h
gdk/wayland/gdkwindow-wayland.c
gdk/wayland/protocol/gtk-shell.xml

index a8211fd47e7cc754b4cfafc2c043db4198803864..cd2e171980013d95821f59bffbbb842e71754a5c 100644 (file)
@@ -42,7 +42,7 @@
 
 #define WL_SURFACE_HAS_BUFFER_SCALE 3
 
-#define SUPPORTED_GTK_SHELL_VERSION 1
+#define SUPPORTED_GTK_SHELL_VERSION 2
 
 #define GDK_WINDOW_IS_WAYLAND(win)    (GDK_IS_WINDOW_IMPL_WAYLAND (((GdkWindow *)win)->impl))
 
index 14ffbe47b19b22a180680025e944608a9cacc6c0..a4e1df436e24ecf26e5a714052e8efe03d08ca37 100644 (file)
@@ -155,8 +155,7 @@ static void gdk_wayland_window_configure (GdkWindow *window,
                                           int        height,
                                           int        scale);
 
-static void maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
-                                                   GdkWindowImplWayland *impl);
+static void maybe_set_gtk_surface_dbus_properties (GdkWindow *window);
 
 GType _gdk_window_impl_wayland_get_type (void);
 
@@ -1007,7 +1006,7 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
 
   xdg_surface_set_app_id (impl->xdg_surface, app_id);
 
-  maybe_set_gtk_surface_dbus_properties (display_wayland, impl);
+  maybe_set_gtk_surface_dbus_properties (window);
 }
 
 static void
@@ -1628,10 +1627,38 @@ gdk_wayland_window_get_type_hint (GdkWindow *window)
   return impl->hint;
 }
 
+static void
+gdk_wayland_window_init_gtk_surface (GdkWindow *window)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  GdkWaylandDisplay *display =
+    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
+
+  if (impl->gtk_surface != NULL)
+    return;
+  if (impl->xdg_surface == NULL)
+    return;
+  if (display->gtk_shell == NULL)
+    return;
+
+  impl->gtk_surface = gtk_shell_get_gtk_surface (display->gtk_shell,
+                                                 impl->surface);
+}
+
 static void
 gdk_wayland_window_set_modal_hint (GdkWindow *window,
                                    gboolean   modal)
 {
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  gdk_wayland_window_init_gtk_surface (window);
+  if (impl->gtk_surface == NULL)
+    return;
+
+  if (modal)
+    gtk_surface_set_modal (impl->gtk_surface);
+  else
+    gtk_surface_unset_modal (impl->gtk_surface);
 }
 
 static void
@@ -2439,9 +2466,10 @@ gdk_wayland_window_set_use_custom_surface (GdkWindow *window)
 }
 
 static void
-maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
-                                       GdkWindowImplWayland *impl)
+maybe_set_gtk_surface_dbus_properties (GdkWindow *window)
 {
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
   if (impl->application.was_set)
     return;
 
@@ -2453,17 +2481,9 @@ maybe_set_gtk_surface_dbus_properties (GdkWaylandDisplay *display_wayland,
       impl->application.unique_bus_name == NULL)
     return;
 
+  gdk_wayland_window_init_gtk_surface (window);
   if (impl->gtk_surface == NULL)
-    {
-      if (impl->xdg_surface == NULL)
-        return;
-
-      if (display_wayland->gtk_shell == NULL)
-        return;
-
-      impl->gtk_surface = gtk_shell_get_gtk_surface (display_wayland->gtk_shell,
-                                                     impl->surface);
-    }
+    return;
 
   gtk_surface_set_dbus_properties (impl->gtk_surface,
                                    impl->application.application_id,
@@ -2484,8 +2504,6 @@ gdk_wayland_window_set_dbus_properties_libgtk_only (GdkWindow  *window,
                                                     const char *application_object_path,
                                                     const char *unique_bus_name)
 {
-  GdkWaylandDisplay *display_wayland =
-    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
   GdkWindowImplWayland *impl;
 
   g_return_if_fail (GDK_IS_WAYLAND_WINDOW (window));
@@ -2500,5 +2518,5 @@ gdk_wayland_window_set_dbus_properties_libgtk_only (GdkWindow  *window,
     g_strdup (application_object_path);
   impl->application.unique_bus_name = g_strdup (unique_bus_name);
 
-  maybe_set_gtk_surface_dbus_properties (display_wayland, impl);
+  maybe_set_gtk_surface_dbus_properties (window);
 }
index bed61d6b29d4c727d0788cbd576471eb5c9bfd1e..fd9974e20fc9c04f80a735ede8aec6cf78b4704a 100644 (file)
@@ -1,6 +1,6 @@
 <protocol name="gtk">
 
-  <interface name="gtk_shell" version="1">
+  <interface name="gtk_shell" version="2">
     <description summary="gtk specific extensions">
       gtk_shell is a protocol extension providing additional features for
       clients implementing it. It is not backward compatible, and a client must
@@ -25,7 +25,7 @@
     </request>
   </interface>
 
-  <interface name="gtk_surface" version="1">
+  <interface name="gtk_surface" version="2">
     <request name="set_dbus_properties">
       <arg name="application_id" type="string" allow-null="true"/>
       <arg name="app_menu_path" type="string" allow-null="true"/>
@@ -34,6 +34,9 @@
       <arg name="application_object_path" type="string" allow-null="true"/>
       <arg name="unique_bus_name" type="string" allow-null="true"/>
     </request>
+
+    <request name="set_modal"/>
+    <request name="unset_modal"/>
   </interface>
 
 </protocol>